<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>实现构造函数的继承</title>
</head>
<body>
    
</body>
</html>
<script>
    "use strict"
    //文章控制器
    //请求数据的时候需要组合成 https://www.xiaobangcai.com?id=1&title=hdcms
    function Article(params={}){
        this.url = "https://www.xiaobangcai.com/article/index";
        //组合请求参数
        let option = Object.keys(params)
        .map(key => key + '=' + params[key]).join('&');
        this.res = `获取数据API:${this.url}?${option}`;
    }

    //用户控制器
    function User(params = {}){
        this.url = "https://www.xiaobangcai.com/user/index";
        //组合请求参数
        let option = Object.keys(params)
        .map(key => {
            return `${key}=${params[key]}`;
        }).join('&');
        this.res = `获取数据API${this.url}?${option}`;
    }


    let hd = new Article({id:1,title:'hdcms'});
    let user = new User({user_id:1,name:'liuhao'});
    document.querySelector('body').innerHTML = user.res;
    
</script>